﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication3
{
    public delegate void myDelegate(string text);
    public partial class Form2 : Form
    {
        public event myDelegate MyEvent;
        public Form2(string text)
        {
            InitializeComponent();
            ////委托传递参数
            //this.textBox_Login.Text = text;
        }
       
        private void button1_Click(object sender, EventArgs e)
        {
            string myLogin  = textBox_Login.Text.Trim();
            string myPasswd = textBox_Passwd.Text.Trim();
           
            if      (myLogin  == "")     { MessageBox.Show("用户不能为空"); return; }
            else if (myLogin != "admin") { MessageBox.Show("用户错误"); return; }
            
            if      (myPasswd == "")      { MessageBox.Show("密码不能为空"); return; }
            else if (myPasswd != "admin") { MessageBox.Show("密码错误"); return; }          
            if (myLogin == "admin" && myPasswd == "admin")
            {
                //进入Form1
                MyEvent(this.textBox_Login.Text);
                this.Close();
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }
    }
}
